# -*- coding: utf-8 -*-
"""
@File: paikao.py
@Time: 2021/12/20 11:34
@Author: 鹄望潇湘
@desc: 

"""

courses = []
teachers = []


def have_course(teacher, date):
    for item in courses:
        if item.get_time()==date:
            if teacher in item.teacher:
                return True
    return False

class Course:
    def __init__(self, date, time, teacher):
        self.date = date
        self.time = time
        self.teacher = teacher
    def get_time(self):
        return self.date


with open("input.txt", "r", encoding="utf-8") as f:
    data = f.readlines()
    for item in data:
        item = item.strip()
        items = item.split("\t")
        date = items[0]
        times = items[1]
        teacher = items[4].split(' ')
        courses.append(Course(date, times, teacher))
        teachers.extend(teacher)


for item in courses:
    if len(item.teacher) == 1:
        for k in teachers:
            if have_course(k, item.date) is False:
                item.teacher.append(k)
                break
    strs = ""
    for k in item.teacher:
        strs=strs+k+" "
    print(strs)


